package com.techwells.learningkites.adapter;

import java.io.Serializable;
import java.util.List;

import com.lidroid.xutils.BitmapUtils;
import com.techwells.learningkites.R;
import com.techwells.learningkites.adapter.CourseVideoListAdapter.CellHolder;
import com.techwells.learningkites.networkaccess.KitesRequestUrl;
import com.techwells.learningkites.networkservice.model.Avatar;
import com.techwells.learningkites.networkservice.model.Page;
import com.techwells.learningkites.networkservice.model.Test;
import com.techwells.learningkites.networkservice.model.Video;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class AvatarGridAdapter extends BaseAdapter {
	
	private Context mContext;
	private LayoutInflater mInflater;
	private List<String> mList;
	private BitmapUtils bitmapUtils;

	
	public AvatarGridAdapter(Context mContext, List<String> mList) {
		super();
		this.mContext = mContext;
		mInflater =(LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		this.mList = mList;
		bitmapUtils = new BitmapUtils(mContext);
	}


	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		CellHolder cellHolder;
        if (convertView == null) {
        	cellHolder = new CellHolder();
        		convertView = mInflater.inflate(R.layout.item_avatarlist, null);
        		cellHolder.img = (ImageView) convertView.findViewById(R.id.item_image);
                convertView.setTag(cellHolder);

        } else {
        	cellHolder = (CellHolder) convertView.getTag();
        }        
       
        bitmapUtils.display(cellHolder.img, KitesRequestUrl.BASE_URL_IMG+mList.get(position));
        
		return convertView;
	}

	
	public static class CellHolder implements Serializable{
    	ImageView img;
    }
}
